﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Wolfy.NetDisk.Core.Model;

namespace Wolfy.NetDisk.Core.Service
{
    /// <summary>
    /// 增删改查服务接口
    /// </summary>
    public interface ICRUDService<T> where T : DeleteEntity, new()
    {
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        int Create(T item);
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        int Update(T item);
        /// <summary>
        /// 保存
        /// </summary>
        void Save();
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        T Get(int id);
        /// <summary>
        /// 获取所有
        /// </summary>
        /// <returns></returns>
        IEnumerable<T> GetAll();
        /// <summary>
        /// 条件
        /// </summary>
        /// <param name="func"></param>
        /// <param name="showDeled"></param>
        /// <returns></returns>
        IEnumerable<T> Where(Expression<Func<T, bool>> func, bool showDeled = false);
        /// <summary>
        /// 还原
        /// </summary>
        /// <param name="id"></param>
        void Restore(int id);
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="ids"></param>
        void BatchDeleted(params int[] ids);
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="ids"></param>
        void BatchRestore(params int[] ids);
    }
}
